package ace.module.upms.core.autoconfig;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.stereotype.Repository;
import org.springdoc.core.models.GroupedOpenApi;
import ace.cmp.jetcache.anno.config.EnableAceMethodCache;
import ace.cmp.spring.data.jdbc.querydsl.core.QuerydslJdbcRepositoryExtendFactoryBean;
import ace.module.upms.core.impl.UpmsCoreBootstrapScanner;
import ace.module.upms.core.impl.dao.repository.RepositoryScanner;
import ace.module.upms.core.impl.properties.UpmsCoreProperties;

/**
* boostrap auto config.
*
* @author Caspar
*/
@EnableAspectJAutoProxy(exposeProxy = true)
@EnableAceMethodCache(basePackageClasses = {UpmsCoreBootstrapScanner.class})
@EnableConfigurationProperties({UpmsCoreProperties.class})
@EnableJdbcRepositories(
    basePackageClasses = {RepositoryScanner.class},
    repositoryFactoryBeanClass = QuerydslJdbcRepositoryExtendFactoryBean.class)
@ComponentScan(
    basePackageClasses = UpmsCoreBootstrapScanner.class,
    excludeFilters = {
      @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Repository.class)
    })
@Configuration
public class UpmsCoreAutoConfig {
    @Bean
    public GroupedOpenApi upmsGroupedOpenApi() {
        return GroupedOpenApi.builder()
                .group("upms")
                .displayName("demo")
                .packagesToScan(UpmsCoreBootstrapScanner.class.getPackageName())
                .build();
    }
}